<!-- 头部 -->
<include file="Public:header" />

        <!-- header-section end-->
        <div class="index-wrapper" style="padding-bottom: 0px;">

            <div class="product-list" style="background: #fff;padding: 10px;margin: 0px;">
                <div class="site-demo-upload" style="text-align: center;padding-bottom: 20px;">
                  <img id="LAY_demo_upload" src="__ROOT__{$userinfo['face']}" style="width: 113px;height: 110px;border: 1px solid #999;border-radius: 8px;">
                  <div class="site-demo-upbar">
                    <input type="file" name="file" class="layui-upload-file" id="test">
                  </div>
                </div>

                <!-- 1 -->
                <form class="layui-form" method="post">
                    <div style="width: 100%;height: 35px;border-bottom: 1px solid #DEDEDE;line-height: 35px;padding-left: 25px;">
                        <div style="float: left;width: 100%;">
                            <!-- <img src="__PUBLIC__/home/images/u3.png" alt="" style="padding: 5px;"> -->
                            <span>昵称：</span>
                            <input type="text" name="names" lay-verify="names" placeholder="请输入昵称" autocomplete="off" value="{$userinfo['name']}" style="border: 0px;">
                            <button lay-submit="names" lay-filter="names" style="width: 60px;height:25px;position: absolute; top:230px;right: 10px;color: #666;">修改昵称</button>
                        </div>
                    </div>
                </form>
                <div style="width: 100%;height: 35px;border-bottom: 1px solid #DEDEDE;line-height: 35px;padding-left: 25px;">
                    <div style="float: left;width: 100%;">
                        <span>手机：</span>
                        {$userinfo.phone}
                        <!-- <img src="__PUBLIC__/home/images/u10.png" alt="" style="float: right;padding: 5px;"> -->
                    </div>
                </div>
            </div>
            <div style="height: 10px;"></div>
            <div class="product-list" style="background: #fff;padding: 10px;margin: 0px;">
                <form class="layui-form" method="post">
                    <div style="width: 100%;height: 35px;border-bottom: 1px solid #DEDEDE;line-height: 35px;padding-left: 25px;">
                        <div style="float: left;width: 100%;">
                            <!-- <img src="__PUBLIC__/home/images/u3.png" alt="" style="padding: 5px;"> -->
                            <span>密码：</span>
                            <input type="password" name="newpass" lay-verify="newpass" placeholder="请输入新密码" autocomplete="off" style="border: 0px;">
                            <button lay-submit="newpass" lay-filter="newpass" style="width: 60px;height:25px;position: absolute; top:330px;right: 10px;color: #666;">修改密码</button>
                        </div>
                    </div>
                </form>
                <a style="width: 100%;height: 20px;">
                    <div style="float: left;width: 100%;">
                        <p style="padding: 20px;font-size: 8px;">注册时间:<?php echo date('Y-m-d H:i:s',$userinfo['time'])?></p>
                    </div>
                </a>
            </div>
            <div style="height: 10px;"></div>
            <!-- 底部 -->
            <div class="tabbar-section" style="text-align: center;font-size: 12px;padding-top: 10px;background: #fff;padding-bottom: 10px;">
                <ul id="J-tabbar" class="ui-flex">
                    <li class="cell">
                        <a class="tabbar-nav" href="{:U('index/index')}">
                            <img src="__PUBLIC__/home/images/sy1.png" alt=""><p style="font-size: 15px;">首页</p>
                        </a>
                    </li>
                    <li class="cell J-other">
                    <?php if (!empty(session('name'))) { ?>
                        <a class="tabbar-nav" href="{:U('setup/index')}">
                            <img src="__PUBLIC__/home/images/fq2.png" alt=""><p style="font-size: 15px;">创建</p>
                        </a>
                    <?php } else { ?>
                        <a class="tabbar-nav" href="{:U('user/login')}">
                            <img src="__PUBLIC__/home/images/fq2.png" alt=""><p style="font-size: 15px;">创建</p>
                        </a>
                    <?php } ?>
                    </li>
                    <li class="cell J-other">
                        <a class="tabbar-nav" href="{:U('index/xms')}">
                            <img src="__PUBLIC__/home/images/xm3.png" alt=""><p style="font-size: 15px;">项目</p>
                        </a>
                    </li>
                    <li class="cell J-other">
                    <?php if (!empty(session('name'))) { ?>
                        <a class="tabbar-nav" href="{:U('user/yhzx')}">
                            <img src="__PUBLIC__/home/images/xwd4.png" alt=""><p style="color:#FF9027;font-size: 15px;">我的</p>
                        </a>
                    <?php } else { ?>
                        <a class="tabbar-nav" href="{:U('user/login')}">
                            <img src="__PUBLIC__/home/images/wd4.png" alt=""><p style="font-size: 15px;">我的</p>
                        </a>
                    <?php } ?>
                    </li>
                </ul>
            </div>
        </div>
<script type="text/javascript">
    layui.use(['form','layer','upload'], function(){
       $ = layui.jquery;
      var layer = layui.layer
      ,form = layui.form();
      //layer.msg('Hello World');
    //自定义验证规则
    form.verify({
      names: function(value){
        if(value.length < 1){
          return '请输入姓名';
        }
      }
      ,newpass: function(value){
        if(value.length < 1){
          return '请输入新密码';
        }
      }
    });
    
    layui.upload({
        url: '{:U("user/face")}' //上传接口
        ,elem: '#test' //指定原始元素，默认直接查找class="layui-upload-file"
        ,success: function(res){ //上传成功后的回调
          //console.log(res)
          //location.reload();
          LAY_demo_upload.src = res.data.src;
        }
    });

      //交互
    form.on('submit(names)', function(data){
        $.ajax({
            url: "{:U('user/names')}",//请求地址
            type: "post",//请求方式
            dataType: "json",//返回数据类型
            data: data.field,//发送的参数
            })
            .done(function(response) {
                  if(response.error==0){
                     layer.msg(response.info ,{icon:5});
                  }else{
                     layer.msg(response.info ,{icon:6});
                     location.reload();
                  }
              })
            .fail(function() {
                alert("ajxs交互失败");
            })  

          return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });   

    form.on('submit(newpass)', function(data){
        $.ajax({
            url: "{:U('user/newpass')}",//请求地址
            type: "post",//请求方式
            dataType: "json",//返回数据类型
            data: data.field,//发送的参数
            })
            .done(function(response) {
                  if(response.error==0){
                     layer.msg(response.info ,{icon:5});
                  }else{
                     layer.msg(response.info ,{icon:6});
                     location.reload();
                  }
              })
            .fail(function() {
                alert("ajxs交互失败");
            })  

          return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });   
 
    });

</script>

    </body>
</html>